package com.voxel.sense.infomsg.module.common;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by chenyiyao on 2017/11/8.
 */

public class SlidingTabPageAdapter extends FragmentPagerAdapter {
    private List<Fragment> mListdata;
    private String[] mTitle = new String[]{};

    public SlidingTabPageAdapter(FragmentManager fm, List list, String[] str) {
        super(fm);
        mListdata = list;
        mTitle = str;
    }

    @Override
    public Fragment getItem(int position) {
        return mListdata.get(position);
    }

    @Override
    public int getCount() {
        return mListdata.size();
    }

    @Override
    public int getItemPosition(Object object) {
        //L.d("-------getItemPosition()");
        return PagerAdapter.POSITION_UNCHANGED;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (mTitle != null) {
            return mTitle[position];
        }
        return null;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }
}
